import Vue from 'vue';
export default {
    namespaced: true,
    state: () => ({
        addressList: [
            {
                username: '吴帅',
                phone: '13322223333',
                loc: [
                    { name: '河北', idx: 2 },
                    { name: '石家庄', idx: 0 },
                    { name: '西区', idx: 2 }
                ],
                detail: '大西洋国际大厦',
                isDefault: true
            },
            {
                username: '刘磊',
                phone: '13444445555',
                loc: [
                    { name: '山西', idx: 3 },
                    { name: '大同', idx: 1 },
                    { name: '矿区', idx: 1 }
                ],
                detail: '山西煤老板1号矿井',
                isDefault: false
            }
        ]
    }),
    mutations: {
        addressUpdateMut(state, { obj, idx }) {
            if (idx == -1) {
                state.addressList.push(obj)//把新增的newaddress加进去
            }
            else {
                state.addressList[idx] = { ...obj };
            }
        },
        addressDelMut(state, idx) {
            state.addressList.splice(idx, 1)
        }
    }
}